package com.zxmc.server.mapper;

import com.github.pagehelper.Page;
import com.zxmc.pojo.dto.NovelQueryDto;
import com.zxmc.pojo.dto.NovelRecommend;
import com.zxmc.pojo.dto.PageNovelQueryDto;
import com.zxmc.pojo.entity.Novel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NovelMapper {
//    @Insert("insert into novel (title, cover, total, lastChapter, updated, author, introduction)" +
//            " values (#{title},#{cover},#{total},#{lastChapter},#{updated},#{author},#{introduction});")
    void insert(Novel novel);

    List<Novel> list(NovelQueryDto novelQueryDto);

    Page<Novel> page(PageNovelQueryDto pageNovelQueryDto);


    void update(Novel novel);

    @Select("select id, hot, boy_or_girl, sort, watch_num, collect_num from novel;")
    List<NovelRecommend> listRecommend();

    @Select("select * from novel where id = #{id}")
    Novel listById(Integer id);

    @Delete("delete from novel where id = #{id}")
    void delete(Novel novel);
    @Select("select id from novel;")
    List<Integer> listAllIds();

    Page<Novel> pageByTag(PageNovelQueryDto pageNovelQueryDto);

    @Select("select * from novel where author = #{author}")
    List<Novel> listByAuthor(String author);
}
